{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "5dec6ddf-f373-45be-8f16-2ec6e43bf410",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "对比项       左臂        右臂        \n",
      "高压最大值     154       155       \n",
      "低压最大值     88        90        \n",
      "压差平均值     59.8      56.2      \n",
      "高压平均值     144.4     140.0     \n",
      "低压平均值     84.6      83.8      \n",
      "结论：左臂血压偏高, 心率的平均值为65.8\n"
     ]
    }
   ],
   "source": [
    "fi = open(\"xueyajilu.txt\",'r')\n",
    "jl = [[],[],[],[],[]]   # 1:zb_h（左臂高压）, zb_l（左臂低压）,yb_h（右臂高压）,yb_l（右臂低压）\n",
    "zyc = []   #左压差\n",
    "yyc = []   #右压差\n",
    "xl  = []   #心率\n",
    "for item in fi:\n",
    "    lls=item.replace('\\n','').strip().split(',')\n",
    "    for i in range(1,5):\n",
    "        jl[i].append(eval(lls[i] ))\n",
    "    zyc.append(eval(lls[1])-eval(lls[2]  ))  #左压差\n",
    "    yyc.append(eval(lls[3])-eval(lls[4]))  #右压差\n",
    "    xl.append(eval(lls[5]))                #心率\n",
    "fi.close()\n",
    "cnt = len(xl) \n",
    "res = []\n",
    "res.append(list((\"高压最大值\",max(jl[1]),max(jl[3]))))\n",
    "res.append(list((\"低压最大值\",max(jl[2]),max(jl[4]))))\n",
    "res.append(list((\"压差平均值\",sum(zyc)/cnt,sum(yyc)/cnt)))\n",
    "res.append(list((\"高压平均值\",sum(jl[1])/cnt,sum(jl[3])/cnt)))\n",
    "res.append(list((\"低压平均值\",sum(jl[2])/cnt,sum(jl[4])/cnt)))\n",
    "res.append(list((\"心率平均值\",sum(xl)/cnt ,0)))\n",
    "zbg = 0\n",
    "ybg = 0\n",
    "print('{:<10}{:<10}{:<10}'.format(\"对比项\", \"左臂\", \"右臂\"))\n",
    "for r in range(len(res)-1):\n",
    "    print('{:<10}{:<10}{:<10}'.format(res[r][0],res[r][1],res[r][2]))\n",
    "    if res[r][1]>res[r][2]:\n",
    "        zbg += 1\n",
    "    else:\n",
    "       ybg += 1\n",
    "if zbg > ybg:\n",
    "    print('结论：左臂血压偏高',end ='')\n",
    "elif zbg == ybg:\n",
    "    print('结论：左臂血压与右臂血压相当',end ='')\n",
    "else:\n",
    "    print('结论：右臂血压偏高',end ='')\n",
    "print(', 心率的平均值为{}'.format(res[5][1]))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "99c3c1df-5455-4be9-8ec9-709c9f9ce703",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "73a320de-0fb2-4f62-9b6e-2d1069fac894",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
